home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / strlibs.zip / MEMMOV.ASM < prev    next >
Assembly Source File  |  1993-01-04  |  1KB  |  59 lines

  1. ;       Static Name Aliases
  2. ;
  3.         TITLE   memmov
  4. ;       NAME    memmov.C
  5.  
  6. ;   memmov(dst, src, len)
  7. ;   moves len bytes from src to dst.  The result is dst+len.
  8. ;   This is to memcpy as str[n]mov is to str[n]cpy, that is, it moves
  9. ;   exactly the same bytes but returns a pointer to just after the
  10. ;   the last changed byte.  You can concatenate blocks pa for la,
  11. ;   pb for lb, pc for lc into area pd by doing
  12. ;       memmov(memmov(memmov(pd, pa, la), pb, lb), pc, lc);
  13. ;   Unlike strnmov, memmov does not stop when it hits a NUL byte.
  14.  
  15.         .287
  16. _TEXT   SEGMENT  BYTE PUBLIC 'CODE'
  17. _TEXT   ENDS
  18. _DATA   SEGMENT  WORD PUBLIC 'DATA'
  19. _DATA   ENDS
  20. CONST   SEGMENT  WORD PUBLIC 'CONST'
  21. CONST   ENDS
  22. _BSS    SEGMENT  WORD PUBLIC 'BSS'
  23. _BSS    ENDS
  24. DGROUP  GROUP   CONST,  _BSS,   _DATA
  25.         ASSUME  CS: _TEXT, DS: DGROUP, SS: DGROUP, ES: DGROUP
  26. EXTRN   __chkstk:NEAR
  27. _TEXT      SEGMENT
  28. ; Line 22
  29.         PUBLIC  _memmov
  30. _memmov PROC NEAR
  31.         push    bp
  32.         mov     bp,sp
  33.         xor     ax,ax
  34.         call    __chkstk
  35.         push    di
  36.         push    si
  37.  
  38. ;       dst = 4
  39. ;       register si = dst
  40. ;       src = 6
  41. ;       register di = src
  42. ;       len = 8
  43.  
  44.         mov     di,[bp+4]       ;dst
  45.         mov     si,[bp+6]       ;src
  46.         mov     cx,[bp+8]
  47.         repnz   movsb
  48.  
  49.         mov     ax,di
  50.         pop     si
  51.         pop     di
  52.         mov     sp,bp
  53.         pop     bp
  54.         ret
  55.  
  56. _memmov ENDP
  57. _TEXT   ENDS
  58. END
  59.